package edu.gyu.myshop.dao;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import edu.gyu.myshop.model.OrderDetail;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author ls
 * @since 2024-06-18
 */
public interface OrderDetailDao extends BaseMapper<OrderDetail> {
    @Select("SELECT od.*, g.name as product_name FROM order_detail od " +
            "JOIN myorder o ON od.orderId = o.id " +
            "JOIN goods g ON od.goodsId = g.id " +
            "WHERE o.status = #{status} order by o.id desc" )
    IPage<OrderDetail> findOrderDetailsByOrderStatus(Page<?> page, @Param("status") Integer status);
}
